/**
 * EDF - Tous droits réservés &copy; 2012 - 2014
 */
package com.mkl.leek.dpsSimulator.vo;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * Representation of a leek player.
 * <p>
 * Dernier commit:
 * <ul>
 * <li>le $Date:$</li>
 * <li>par $Author:$</li>
 * <li>revision $Revision:$</li>
 * </ul>
 * </p>
 *
 * @author MC07461S
 */
public class Leek {
    /** Stats of the leek (agility, force, ...). */
    private Stats stats;
    /* List of the buffes of the leek. */
    private List<Effect> buffes = new ArrayList<>();
    /** List of the attacks of the leek. */
    private List<Action> attacks = new ArrayList<>();

    /**
     * Representation of an effect, or a buff: it has a start turn, an end turn, a stat
     * that it boostes and a value.
     */
    private class Effect {
        /** First turn of application of the effect (included). */
        private int startTurn;
        /** Last turn of application of the effect (included). */
        private int endTurn;
        /** Stat concerned by the effect. */
        private StatEnum stat;
        /** Value of the effect. */
        private BigDecimal value;

        /**
         * Default constructor.
         * @param effect effect in general to apply.
         * @param turn of application of the effect.
         */
        public Effect(AbsoluteEffect effect, int turn) {
            this.startTurn = turn;
            this.endTurn = turn + effect.getDuration() - 1;
            this.stat = effect.getStat();
            this.value = effect.getValue();
        }

        /**
         * Tests if the effect is still applied at the turn testTurn.
         * @param testTurn turn to test.
         * @return <code>true</code> if the effect if active, <code>false</code> otherwise.
         */
        public boolean contains(int testTurn) {
            return startTurn <= testTurn && testTurn <= endTurn;
        }

        /** @return the startTurn. */
        public int getStartTurn() {
            return startTurn;
        }

        /** @return the endTurn. */
        public int getEndTurn() {
            return endTurn;
        }

        /** @return the stat. */
        public StatEnum getStat() {
            return stat;
        }

        /** @return the value. */
        public BigDecimal getValue() {
            return value;
        }
    }
}
